<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
    <%@ page language="java" import="java.sql.*"
import="java.util.List" 

import ="javax.ws.rs.core.MediaType" 
import ="javax.ws.rs.core.UriBuilder" 

import=" com.sun.jersey.api.client.*" 
import= "com.sun.jersey.api.client.config.ClientConfig" 
import= "com.sun.jersey.api.client.config.DefaultClientConfig" 

import ="classes.Tip" 
import ="classes.Vrsta" 

 errorPage="" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>eKupi.ba</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="JavaScript">
	
	function validacija()
	{
		
		
		
	    if(document.loginForma.naziv.value=="")
	    {
	    	alert("Naziv nije unesen.");
	      	document.loginForma.naziv.focus();
	      	return false;
	    }
	}
	
	
	
	
	</script>
</head>
<body>

<div id="main_container">
	<div id="header">
    	<div class="logo"><img src="images/logo12.png" border="0" width="300" height="80" alt="" title="" /></div>       
    </div>
        <div class="menu">
        	<ul> 
        		<li class="selected"><a href="#">tipovi</a></li>
        		<li class="unselected"><a href="vrste.jsp">vrste</a></li>                                                                        
        		<li class="unselected"><a href="proizvodi.jsp">proizvodi</a></li>
        		        		
                <li><a href="pocetna.jsp">home</a></li>
				
			
        	</ul>
        </div>
        
    <div class="center_content">
    
     	<div class="center_left">
        
        
           
         
         
         <div class="features">   
            <div class="title">TIPOVI</div>
            
            <%
            
            try {
            	
            	ClientConfig config1 = new DefaultClientConfig();
	   			 Client client = Client.create(config1);
	   			
	   			 WebResource service = client.resource(UriBuilder.fromUri("http://localhost:8080/eKupovina").build());
//	   			List<Proizvod> proizvodi= service.path("webservices").path("proizvodi").path("svi").accept(MediaType.APPLICATION_XML).get(new  GenericType<List<Proizvod>>() {});
	   						  
	  			  
        	
        					out.print("uhsdfius");
        	%>
        	
        		 <div class="news_box">
                <div class="news_icon"></div>
                <div class="news_content">
                <a href="oNama.html"  class="read_more">Izbriši</a>
                </div>   
            </div>
        		
        	<%
        		
            }
            catch(Exception e) { e.printStackTrace();}
            
            
            if(request.getParameter("naziv")!=""){
            try {
            	
            	ClientConfig config1 = new DefaultClientConfig();
	   			 Client client = Client.create(config1);
	   			
	   			 WebResource service = client.resource(UriBuilder.fromUri("http://localhost:8080/eKupovina").build());
	   			Tip t= new Tip();
	   			t.setNaziv(request.getParameter("naziv"));
	   			String s=service.path("webservices").path("tipovi").path("tip").path("novi").header("username", session.getAttribute("sKorisnickoIme")).header("password", session.getAttribute("sKorisnickoIme")).accept(MediaType.APPLICATION_XML).put(String.class, t);
        					out.print("uspješno dodat novi tip");
        					} 
        					catch(Exception e) { e.printStackTrace();
        					}
            }
            else
            	System.out.println("GREEEESKA");
        	%>
            
               
                
               
       
         <br><br><br><br> <br><br><br><br> <br><br><br><br><br>
           
             
             
              <div class="title">DODAJ NOVI TIP</div><br>
             
               <div class="text_box">
                        <div class="title">Unesite podatke o tipu</div>
                        
                            <div class="login_form_row">
                            <form name="loginForma" onSubmit="return validacija();" action="tipovi.jsp"  method="post">
                           		 <label class="login_label">Naziv:</label><input type="text" name="naziv" class="login_input" />
                           	 </div>                            
                        	</form>
                        	
                        	<form name="registerForma" action="tipovi.jsp" method="get" >
                        	<input type="image" name="registracija" src="images/registracija.gif"  class="login" />  
                        	</form>
                             </div>
             
             
             
                  </div>      
            
        </div> 
        
        
        
        
        
        
        
        
        
        
        
        <div class="center_right">
        
        <div class="software_box"><img src="images/aaa.png" width="200" height="200" alt="" title="" /></div>
        
       	
                    <div class="text_box">
                     <div class="title">Dobrodošli  u <i><%out.print(session.getAttribute("sKorisnickoIme"));%> </i></div>
                        
                        <form action="provjeriLogout.jsp">
                            
                            <div class="login_form_row">
                            	<label class="login_label"><strong>Market:</strong></label><label class="login_label"><%out.print(session.getAttribute("sIme"));%></label>
                            </div>
                            
                              
							<br>
							<br>
							<br>
							<br>
							<input type="image" src="images/logout.gif" class="login"   />       
							</form>                       
					</div>
                        
					<div class="testimonials">
						<div class="title">Novosti</div>
						<div class="text_box">
							<p class="testimonial">
							Ovdje se unose novosti
							<strong>Autor</strong>
						 </p>
						
						
						</div>                    
					
					</div>
        

        </div>  
        
        <div class="clear"></div> 
    
    </div>    

    
    <div id="footer">                                              
        <div class="left_footer"><a href="pocetna.jsp">home</a> <a href="oNama.html">o nama</a> <a href="kontakt.html">kontakt</a></div>
        <div class="right_footer">
        </div>   
    
    </div>
    
    
    
</div>
<!-- end of main_container -->

</body>
</html>